package com.ruoyi.hr.controller.hr.depInfo;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.hr.domain.Authority;
import com.ruoyi.hr.service.AuthorityService;
import com.ruoyi.hr.service.depinfo.DepInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 部门信息
 */
@Controller
@RequestMapping("/dep/info")
public class DepInfoController extends BaseController {

    @Autowired
    DepInfoService depInfoService;

    @Autowired
    AuthorityService authorityService;

    private String prefix = "hr/depinfo";

    /**
     * 有效
     */
    @GetMapping("/yx")
    public String depInfoYx() {
        return prefix + "/depInfoYx";
    }

    /**
     * 失效
     */
    @GetMapping("/sx")
    public String depInfoSx() {
        return prefix + "/depInfoSx";
    }

    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam Map map) {
        Authority authority = authorityService.findAuthorAndIsAdmin();
        startPage();
        List<Map<String, Object>> maps = depInfoService.findData(map, authority);
        return getDataTable(maps);
    }
}
